package com.xiaomengkuan.plugin.controller;

import com.xiaomengkuan.common.util.R;
import com.xiaomengkuan.plugin.service.CosService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 腾讯云接口
 *
 * @author Faraj Mujey
 * -- Creation Time: 2021-01-27 4:13 下午, File Encoding: utf8 --
 */
@RestController
@RequestMapping("plugin/cos")
public class CosController {
    @Resource
    private CosService cosService;


    @GetMapping("getSignature")
    public String getSignature() {
        try {
            return cosService.signature();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return R.err().toString();
    }

    @PostMapping("upload")
    public R upload(@RequestParam("file") MultipartFile file) {
        return cosService.upload(file);
    }
}
